package com.sumainfor.pc.market.service;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.dao.HousingMapper;
import com.sumainfor.pc.market.feign.EpcFeign.EpcFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 功能描述:
 * 维修工单
 * @Auther: zhlu
 * @Date: 2019/5/9 11:30
 * @Description:
 */
@Service
public class RepairService {

    @Autowired
    EpcFeign EpcFeign;

    @Autowired
    CommunityService CommunityService;

    @Autowired
    private HousingMapper housingMapper;

    public JsonResult getManagerRepairList(Map<String,Object> params){
        if (params.containsKey("Building")) {
            List<String> houseIdList = housingMapper.getHouseIdListByBuildAndRoom(params);
            params.put("houseIdList", houseIdList);
        }
        //获取项目编号
        List<Map<String,Object>>SelectCommunityList=CommunityService.SelectCommunityList(params);
        List<String>ComIdList=new ArrayList<String>();
        if (!params.containsKey("ComIdList")) {
            //如果参数中没有省市区编号。就直接查询默认
            if(FieldCheckUtil.isMapFieldNotNull(params,new String[]{"ProvinceID"})||
                    FieldCheckUtil.isMapFieldNotNull(params,new String[]{"CityID"})||
                    FieldCheckUtil.isMapFieldNotNull(params,new String[]{"DistrictID"})||
                    FieldCheckUtil.isMapFieldNotNull(params,new String[]{"StreetID"})){
                for (Map<String,Object> map:SelectCommunityList){
                    ComIdList.add(map.get("ComId").toString());
                }
            }
            params.put("ComIdList",ComIdList);
        }
        JsonResult jsonResult=EpcFeign.getManagerRepairList(params);
        return jsonResult;
    }

}
